<?php

include 'recharge/abstract.php';
/**
 * 向忍者无双游戏充值
 * @author Kerry
 *
 */
class Recharge_Rezhewushuang extends Recharge_Abstract
{
	/**
	 * 加密key
	 * **/
	const SERCET_KEY = 'A5qVgL&B6rWhM-C7';
	
	/***
	 * 
	 * 虚拟货币和金额兑换比列
	 * 
	 * **/
	const CASH_SCALE = 10;
	
	/**
	 * 
	 * 充值成功状态
	 * 
	 * ***/
	const GAME_RECHARGE_STATUS_SUCCESS = 0;
	


	protected function _makeParams(array $param)
	{
		//$orderId,$userId, $serverId, $amount, $roleId = '',$payMode=''
		$params = array(
		    'm_cash'=>$param['order_amount'] * self::CASH_SCALE,//获得虚拟币的数量
		    'ip'    => $this->getClientIP(),
			'pay_amt'=>$param['order_amount'],//用户充值实际人民币数量
		    'order_id'=>$param['order_number'],
		    'server_id'=>$param['server_no'],//服务器代号 [int] （服务区ID）		
		    'time'     =>time(),
		    'pay_type'=> $param['fromid'],
		    'uid'=>$param['user_id'],
		);
		return $params;
	}
	//生成签名
	protected function _makeSign($params)
	{
		$sign = '';
		foreach(array_values($params) as $value){
		   $sign.=$value;
		} 
		$sign.=self::SERCET_KEY;
		//$sign = md5(implode(".",array_values($params)));
		$sign = md5($sign);
		return $sign;
	}	
	
	/**
	 * @author Kerry
	 * @param array $result
	 * @return boole
	 * **/
	
	public function checkGameRechargeSuccess($result)
	{
	    $rechargeGet = json_decode($result);
	    return $rechargeGet->status == self::GAME_RECHARGE_STATUS_SUCCESS ? true : false;
	}
}